﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using ReflectionStudio.Core.Events;
using WPFExcelReport.Helpers;
using System.Collections.Generic;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class UIABAUFM : ViewBase
    { 
        public UIABAUFM()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 

        }
        /// <summary>
        /// SetProd 当前订单
        /// SetData保存所有订单，但是用于展示今日订单
        /// SetEnv保存所有订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded) return;
            base.Window_Loaded(sender, e);
        }
         
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwMU = dwMaster;
        }
        
        public override void Save()
        {
            base.Save();
            if (dwMU == null)
                return;

        }
          
        public void LOADBYVKAUF(MessageInfo msg)
        {
            base.LOADBYAUF();
            VKAUF = msg.AUFTYP + msg.ORDER; 
        }
       
    }
    public partial class UIABAUFM
    {
        public VABAUFM TMV
        {
            get
            {
                return (VABAUFM)MV;
            }
        }
        #region ==FTMUREV===========
        public static readonly DependencyProperty FTMUREVProperty = DependencyProperty.Register("FTMUREV",
            typeof(bool), typeof(UIABAUFM),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTMUREVChanged));
        public bool FTMUREV
        {
            get
            {
                return (bool)GetValue(FTMUREVProperty);
            }
            set
            {
                SetValue(FTMUREVProperty, value);
            }
        }
        private static void OnFTMUREVChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAUFM;
            if (src != null)
            {
                src.FTMUREV = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==dwMU===========
        public static readonly DependencyProperty dwMUProperty = DependencyProperty.Register("dwMU",
            typeof(DataRow), typeof(UIABAUFM),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwMUChanged));
        public DataRow dwMU
        {
            get
            {
                return (DataRow)GetValue(dwMUProperty);
            }
            set
            {
                SetValue(dwMUProperty, value);
            }
        }
        private static void OdwMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAUFM;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwMU = row;
            }
        }
        #endregion

        #region ==FTMU===========
        public static readonly DependencyProperty FTMUProperty = DependencyProperty.Register("FTMU",
            typeof(bool), typeof(UIABAUFM),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTMUChanged));
        public bool FTMU
        {
            get
            {
                return (bool)GetValue(FTMUProperty);
            }
            set
            {
                SetValue(FTMUProperty, value);
            }
        }
        private static void OnFTMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAUFM;
            if (src != null)
            {
                src.FTMU = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==VKAUF===========
        public static readonly DependencyProperty VKAUFProperty = DependencyProperty.Register("VKAUF",
            typeof(string), typeof(UIABAUFM),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKAUFChanged));
        public string VKAUF
        {
            get
            {
                return (string)GetValue(VKAUFProperty);
            }
            set
            {
                SetValue(VKAUFProperty, value); 
                OnVKAUFChg(value);
            }
        }
        private static void OnVKAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAUFM;
            if (src != null)
            {
                src.VKAUF = (string)e.NewValue;
            }
        }
        public virtual void OnVKAUFChg(string value)
        { }
        #endregion

        #region ==ABAUF===========
        public static readonly DependencyProperty ABAUFProperty = DependencyProperty.Register("ABAUF",
            typeof(string), typeof(UIABAUFM),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABAUFChanged));
        public string ABAUF
        {
            get
            {
                return (string)GetValue(ABAUFProperty);
            }
            set
            {
                SetValue(ABAUFProperty, value); 
             }
        }
        private static void OnABAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAUFM;
            if (src != null)
            {
                src.ABAUF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==EXTPROD===========
        public static readonly DependencyProperty EXTPRODProperty = DependencyProperty.Register("EXTPROD",
        typeof(string), typeof(UIABAUFM),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnEXTPRODChanged));
        public string EXTPROD
        {
            get
            {
                return (string)GetValue(EXTPRODProperty);
            }
            set
            {
                SetValue(EXTPRODProperty, value);
                OnEXTPRODChg(value);
            }
        }
        private static void OnEXTPRODChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAUFM;
            if (src != null)
            {
                src.EXTPROD = (string)e.NewValue;
            }
        }
        public virtual void OnEXTPRODChg(string value)
        {
            if (dwMaster == null)
                return;

        }
        #endregion

    }
}
